<?php
/*
 * 全局函数
 */

function require_cache($sName){
    static $aFiles=array();
    if (!isset($aFiles[$sName])){
        if (IS_WIN && basename(realpath($sName)) == basename($sName)){
            require $sName;
            $aFiles[$sName] = true;
        }else {
            $aFiles[$sName] = false;
            if (!IS_WIN){
                require $sName;
                $aFiles[$sName] = true;
            }
        }
    }
    return $aFiles[$sName];
}


function import($sName){
    static $aInclude = array();
    if (!isset($aInclude[$sName])){
        $aInclude[$sName] = false;
        if (IS_WIN && basename(realpath($sName)) == basename($sName)){
            $aInclude[$sName] = include $sName;
        }
    }
    return $aInclude[$sName];
}

/**
 * 规范命名
 * @param string $sName
 * @param string $sType   0、java转c风格(下划线); 1、c转java风格(驼峰命名)
 */
function parse_name($sName, $sType = 0){
    if ($sType){
        $sName = ucfirst(preg_replace_callback('@_([a-zA-Z])@', function($sRes){return strtoupper($sRes[1]);}, $sName));
    }else{
        $sName = strtolower(trim(preg_replace('@[A-Z]@', "_\\0", $sName),'_'));
    }
    return $sName;
}


function redirect($sTargetUrl, $sInfo='', $iTime = 3){
    if ($iTime){
        $oView = new View();
        $oView ->render();
    }else{
        
    }
}







